package jjn.round1;

/**
 * @author Jjn
 * @since 2022/8/16 23:53
 */
public class LeetCode278_FirstBadVersion extends VersionControl {

    public LeetCode278_FirstBadVersion(int minBadVersion) {
        super(minBadVersion);
    }

    public int firstBadVersion(int n) {
        int low = 1, high = n;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            if (isBadVersion(mid)) {
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        return low;
    }
}
